#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
@File    :   models.py
@Time    :   2025/10/31 16:28:04
@Author  :   Rico Chen 
@Mail    :   55059@qq.com
@Version :   1.0
@Desc    :   数据库日志
'''
from datetime import datetime
from typing import List, Optional

from fastapi_amis_admin.amis.components import ColumnImage, InputImage, InputRichText
from fastapi_amis_admin.models import ChoiceType,IntegerChoices,Field
from fastapi_user_auth.auth.models import User
from fastapi_user_auth.mixins.models import PkMixin
from sqlalchemy import Column, String, Text, select
from sqlalchemy.orm import Session
from sqlmodel import Relationship
from sqlmodelx import SQLModel

# 审计日志模型
class AuditLog(SQLModel, table=True):
    id: Optional[int] = Field(default=None, primary_key=True, nullable=False)
    user_id: str = Field("", title="用户ID")
    username: str = Field("", title="用户名")
    operation_type: str = Field("", title="操作类型")  # INSERT, UPDATE, DELETE
    table_name: str = Field("", title="操作表名")
    record_id: str = Field("", title="记录ID")
    sql_statement: str = Field("", title="SQL语句")
    operation_time: datetime = Field(default_factory=datetime.now, title="操作时间")
    ip_address: str = Field("", title="IP地址")
